﻿using System;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Runtime.InteropServices;


namespace Version3.SharePoint
{
    //If you want to have a custom display format for your
    //freezed dried data on SharePoint forms, then inherit
    //this class and over ride Render.
    [CLSCompliant(false)]
    [Guid("403D9630-55F8-4353-8606-997F770AB811")]
    public class FreezeDriedDataFieldRenderer
    {
        private object _RehydratedObject = null;

        public void HydrateThis(string freezeDriedData)
        {
            Exception hydrationError = null;
            _RehydratedObject = FreezeDriedDataFieldValue.HydrateObjectFromBase64String(freezeDriedData, ref hydrationError);
            if (null != hydrationError)
            {
                throw hydrationError;
            }
        }

        public object RehydratedObject
        {
            get
            {
                return _RehydratedObject;
            }
        }

        virtual public void Render(Panel formPanel)
        {
            //you need to do this, if you dont we will report an error here
            //you can access your object in base.RehydratedObject
            //You have a DIV for this not a generic writer
            //thats intentional!
        }
    }
}
